import React, {
    PureComponent
} from 'react';

import {
    events,
    onEvent
} from './utils/analytics';

import {
    StatusBar
} from 'react-native';

import {
    Provider
} from 'react-redux';

import Store,{
    persist
} from './state';

import Plug from './plug';

import Router from './router';

import {
    RootSiblingParent
} from 'react-native-root-siblings';

import {
    PersistGate
} from 'redux-persist/integration/react';

import {
    SafeAreaProvider
} from 'react-native-safe-area-context';

const setStatusBar = () => {
    // StatusBar.setBackgroundColor('transparent',true);
}

class App extends PureComponent {

    componentDidMount() {
        setStatusBar();
        onEvent(events[`app启动`]);
    }

    render() {
        return (
            <SafeAreaProvider>
                <Provider store={Store}>
                    <PersistGate persistor={persist}>
                        <RootSiblingParent>
                            <Plug children={<Router/>} />
                        </RootSiblingParent>
                    </PersistGate>
                </Provider>
            </SafeAreaProvider>
        )
    }
}

export default App;